package com.borko.healthcare.tapestry.services;

import org.apache.tapestry5.ValueEncoder;

import com.borko.healthcare.entities.interfaces.Order;
import com.borko.healthcare.persistence.hibernate.services.OrderManager;

@SuppressWarnings("rawtypes")
public class OrderEncoder implements ValueEncoder {
	
	private OrderManager orderManager;
	
	public OrderEncoder(OrderManager orderManager) {
		super();
		this.orderManager = orderManager;
	}

	public String toClient(Object value) {
		return ((Order)value).getId() + "";
	}

	public Object toValue(String clientValue) {
		return orderManager.getOrder(Integer.parseInt(clientValue));
	}

}
